#pragma once
#include "../Gui.h"

//---------------------------------------------------------------------
enum ValueType
{
    VAL_ERROR,
    VAL_DWORD,
    VAL_MULTISZ,
    VAL_SZ,
    VAL_BINARY
};
//---------------------------------------------------------------------

class GUI_API CReg  
{
public:
    BOOL		CheckKeyExist(HKEY hkRoot,LPCTSTR pszKey);
    ValueType	GetValueType(LPCTSTR szName);
    BOOL DeleteKey(LPCTSTR szName);
    BOOL DeleteValue(LPCTSTR szName);
    BOOL SetMultiSZ(LPCTSTR szName, LPCTSTR lpszValue, DWORD dwLen);
    BOOL SetBinary(LPCTSTR szName, LPBYTE lpbValue, DWORD dwLen);
    BOOL SetDW(LPCTSTR szName, DWORD dwValue);
    BOOL SetSZ(LPCTSTR szName, LPCTSTR szValue);
    BOOL SetSZ(LPCTSTR szName, LPCTSTR szValue, DWORD dwLen);
    DWORD GetValueDW(LPCTSTR szName, DWORD dwDefault=0);
    DWORD GetValueBinary(LPCTSTR szName, LPBYTE lpbValue, DWORD dwLen);
    DWORD GetValueSZ(LPCTSTR szName, LPTSTR szValue, DWORD dwLen);
    BOOL EnumValue(LPTSTR pszName, DWORD dwLenName, LPBYTE lpValue, DWORD dwLenValue);
    BOOL EnumKey(LPTSTR psz, DWORD dwLen);
    BOOL IsOK();
    operator HKEY();
    void Reset();
    CReg(HKEY hkRoot, LPCTSTR pszKey);
    BOOL Open(HKEY hkRoot, LPCTSTR pszKey, REGSAM sam = KEY_ALL_ACCESS);
	BOOL  Close();
    BOOL Create(HKEY hkRoot, LPCTSTR pszKey);
    CReg();
    virtual ~CReg();

private:
    HKEY       m_hKey;
    int        m_Index;
    LPBYTE     m_lpbValue; // last value read, if any
};
